package com.rsstuan.storage.data;

import java.text.DecimalFormat;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable(identityType = IdentityType.APPLICATION) 
public class TuanGouItemData {
	 @PrimaryKey 
	 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
	 private Long id;
	 
	 @Persistent
	 private Long channelId;
	 
	 @Persistent
	 private Long siteId;
	 
	 @Persistent
	 private String title;
	 
	 @Persistent
	 private String link;
	 
	 @Persistent
	 private String city;
	 
	 @Persistent
	 private String image;
	 
	 @Persistent
	 private Double price;
	 
	 @Persistent
	 private Double origPrice;
	 
	 @Persistent
	 private Long pubTime;
	 
	 @Persistent
	 private Long startTime;
	 
	 @Persistent
	 private Long endTime;
	 
	 @Persistent
	 private int orderNum;
	 
	 @Persistent
	 private String address;
	 
	 @Persistent
	 private String description;
	 
	 @Persistent
	 private Long storeTime;
	 
	 @Persistent
	 private Long updateTime;
	 
	 @Persistent
	 private boolean activate;
	 
	 private Long leftTime;

	 @Persistent
	 private List<String> tags;
	 
	 @Persistent
	 private Integer click;
	 
	 @Persistent 
	 private Double totalScore;
	 
	 @Persistent
	 private Integer scorePeople;

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public Double getOrigPrice() {
		return origPrice;
	}

	public void setOrigPrice(double origPrice) {
		this.origPrice = origPrice;
	}

	public Long getStartTime() {
		return startTime;
	}

	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	public Long getEndTime() {
		return endTime;
	}

	public void setEndTime(long endTime) {
		this.endTime = endTime;
	}

	public int getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(int orderNum) {
		this.orderNum = orderNum;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Long getStoreTime() {
		return storeTime;
	}

	public void setStoreTime(long storeTime) {
		this.storeTime = storeTime;
	}

	public Long getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(long updateTime) {
		this.updateTime = updateTime;
	}


	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setChannelId(Long channelId) {
		this.channelId = channelId;
	}

	public Long getChannelId() {
		return channelId;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCity() {
		return city;
	}

	public void setSiteId(Long siteId) {
		this.siteId = siteId;
	}

	public Long getSiteId() {
		return siteId;
	}

    public void setActivate(boolean activate) {
        this.activate = activate;
    }

    public boolean isActivate() {
        return activate;
    }

	public Long getPubTime() {
		return pubTime;
	}

	public void setPubTime(long pubTime) {
		this.pubTime = pubTime;
	}

	public List<String> getTags() {
		return tags;
	}


	public void setTags(List<String> tags) {
		this.tags = tags;
	}

	/**
	 * @return the leftTime
	 */
	public Long getLeftTime() {
		return leftTime;
	}

	/**
	 * @param leftTime the leftTime to set
	 */
	public void setLeftTime(Long leftTime) {
		this.leftTime = leftTime;
	}

	/**
	 * @param price the price to set
	 */
	public void setPrice(Double price) {
		this.price = price;
	}

	/**
	 * @param origPrice the origPrice to set
	 */
	public void setOrigPrice(Double origPrice) {
		this.origPrice = origPrice;
	}

	/**
	 * @param pubTime the pubTime to set
	 */
	public void setPubTime(Long pubTime) {
		this.pubTime = pubTime;
	}

	/**
	 * @param startTime the startTime to set
	 */
	public void setStartTime(Long startTime) {
		this.startTime = startTime;
	}

	/**
	 * @param endTime the endTime to set
	 */
	public void setEndTime(Long endTime) {
		this.endTime = endTime;
	}

	/**
	 * @param storeTime the storeTime to set
	 */
	public void setStoreTime(Long storeTime) {
		this.storeTime = storeTime;
	}

	/**
	 * @param updateTime the updateTime to set
	 */
	public void setUpdateTime(Long updateTime) {
		this.updateTime = updateTime;
	}
	
	public Double getSavePrice() {
	    if (origPrice != null && price != null) {
	        return origPrice - price;
	    }
	    return null;
	}
	
	public Double getDiscount() {
	    DecimalFormat df = new DecimalFormat("0.0");
	    if (origPrice != null && origPrice > 0 && price != null) {
	    	try {
	    		return Double.parseDouble(df.format(price * 10 / origPrice));
	    	} catch (Exception e) {
	    		return 0.0D;
	    	}
	    	
	    } else {
	    	return 0.0D;
	    }
	   
	   
	}

	public int getClick() {
		if (click == null)
			return 0;
		return click;
	}

	public void setClick(int click) {
		this.click = click;
	}

    public double getTotalScore() {
        if (totalScore == null)
            return 0.0;
        return totalScore;
    }

    public void setTotalScore(double totalScore) {
        this.totalScore = totalScore;
    }

    public int getScorePeople() {
        if (scorePeople == null)
            return 0;
        return scorePeople;
    }

    public void setScorePeople(int scorePeople) {
        this.scorePeople = scorePeople;
    }
	 
	
	 

}
